package com.JustTest;

import org.apache.kafka.clients.producer.Callback;
import org.apache.kafka.clients.producer.KafkaProducer;
import org.apache.kafka.clients.producer.ProducerRecord;
import org.apache.kafka.clients.producer.RecordMetadata;

import java.util.Properties;
import java.util.concurrent.ExecutionException;

/**
 * Created by mike on 18/1/31.
 */
public class Productor {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        Properties properties = new Properties();
        properties.setProperty("bootstrap.servers","localhost:9092,localhost:9093,localhost:9094");
        properties.setProperty("key.serializer","org.apache.kafka.common.serialization.StringSerializer");
        properties.setProperty("value.serializer","org.apache.kafka.common.serialization.StringSerializer");
        properties.setProperty("ack","all");
        KafkaProducer<String,String> producer = new KafkaProducer<String, String>(properties);
        ProducerRecord record = new ProducerRecord("mytest2",String.valueOf(Math.random()),String.valueOf(Math.random()));
        producer.send(record).get();
    }
}
